# 初始化文件
from flask import Flask
from .views import blue
from .exts import init_exts


def create_app():
    app = Flask(__name__)
    app.register_blueprint(blueprint=blue)

    # 配置数据库
    #db_uri = 'sqlite:///sqlite3.db'
    db_uri = 'mysql+pymysql://root:Root@127.0.0.1:3306/flaskdb2'  # mysql的配置
    app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    # 初始化插件
    init_exts(app=app)

    return app